

//
//  SYDEndTheTripView.m
//  PinGJByOwnerSide
//
//  Created by lantaiyuan on 2017/8/17.
//  Copyright © 2017年 lantaiyuan. All rights reserved.
//

#import "SYDEndTheTripView.h"
#import "YMTravelTrack.h"
@interface SYDEndTheTripView()
@property (weak, nonatomic) IBOutlet UILabel *startLocationLbl;
@property (weak, nonatomic) IBOutlet UILabel *endLocationLbl;
@property (weak, nonatomic) IBOutlet UILabel *distanceLbl;
@property (weak, nonatomic) IBOutlet UILabel *timesLbl;
@property (weak, nonatomic) IBOutlet UILabel *numbersLbl;
@property (weak, nonatomic) IBOutlet UILabel *amountLbl;
@property (weak, nonatomic) IBOutlet UIButton *cancelBtn;
@property (weak, nonatomic) IBOutlet UIButton *sureBtn;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *constraintW;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *constraintH;

@end
@implementation SYDEndTheTripView

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self = [[NSBundle mainBundle]loadNibNamed:NSStringFromClass([SYDEndTheTripView class]) owner:nil options:nil].lastObject;
        self.frame = frame;
    }
    return self;
}

-(void)awakeFromNib{
    [super awakeFromNib];
    
    self.constraintW.constant = (self.width - 15 * 5) / 4.0;
    self.constraintH.constant = (self.width - 15 * 5) / 4.0;
    
    WEAKSELF
    [[weakSelf.cancelBtn rac_signalForControlEvents:UIControlEventTouchUpInside]subscribeNext:^(__kindof UIControl * _Nullable x) {
        if (weakSelf.cancelBlock) {
            weakSelf.cancelBlock();
        }
    }];
    
    [[weakSelf.sureBtn rac_signalForControlEvents:UIControlEventTouchUpInside]subscribeNext:^(__kindof UIControl * _Nullable x) {
        if (weakSelf.sureBlock) {
            weakSelf.sureBlock();
        }
    }];
}

- (void)setModel:(YMConfirmEndTravel *)model{
    self.startLocationLbl.text = model.firstStationName;
    self.endLocationLbl.text = model.lastStationName;
    self.distanceLbl.text = [NSString stringWithFormat:@"%.2f",model.totalDistance / 1000.0];
    self.timesLbl.text = [NSString stringWithFormat:@"%.2f", model.totalTimeConsuming / 3600.0];
    self.numbersLbl.text = [NSString stringWithFormat:@"%ld", model.totalCount];
    self.amountLbl.text = [NSString stringWithFormat:@"%.2f", model.totalIncome];
    
}
@end
